using System.Collections;
using System.Collections.Generic;
using System.Data;
using TMPro;
using UnityEngine;

public class UI_StatSlot : MonoBehaviour
{
    [SerializeField] private statType _statType;
    [SerializeField] private TextMeshProUGUI statValueText;
    [SerializeField] private TextMeshProUGUI statNameText;
    [SerializeField] private string statName;

    private void OnValidate()
    {

        gameObject.name = "Stat - " + _statType.ToString();

        if(statNameText != null)
            statNameText.text = statName;
    }

    private void Start()
    {
        UpdateStatValueUI();
    }

    public void UpdateStatValueUI()
    {
        PlayerStats playerStats = PlayerManager.instance.player.GetComponent<PlayerStats>();

        if (statValueText != null)
        {
            if(_statType == statType.current_hp)
                statValueText.text = playerStats.current_hp.ToString();
            else
                statValueText.text = playerStats.GetStat(_statType).GetValue().ToString();
        }
    }
}
